const label = {
  data () {
    return {
      labelItem: {},
      labelList: [],
      labelContact: []
    }
  },
  methods: {
    // 取我的标签
    findLabel () {
      this.$axios({
        method: 'post',
        url: `${this.$site.oaServer}/front/retrieve/findLabel.htm`
      }).then(res => {
        this.labelList = res.data.result.map((item) => {
          this.$set(item, 'hover', false)
          this.$set(item, 'isLabel', true)
          this.$set(item, 'checked', false)
          this.$set(item, 'label', item.title)
          return item
        })
        // 是否在部门组件
        if (this.isDepartLabel) {
          this.setLabel()
        } else {
          this.labelList[0].hover = true
          this.labelItem = this.labelList[0]
          this.labelcontact()
        }
      })
    },
    labelHandle (item) {
      this.labelList.forEach(x => {
        x.hover = item.lid === x.lid
      })
      this.labelItem = item
      this.labelcontact()
    },
    labelcontact (lid) {
      const data = {
        'query.lid': lid || this.labelItem.lid,
        'query.schCond': this.searchName,
        'query.lbId': 0,
        'query.schType': 1,
        'query.pageSize': 1000,
        'query.currentPage': 1
      }
      this.$axios({
        method: 'post',
        url: `${this.$site.oaServer}/front/retrieve/labelcontact.htm`,
        data: this.$qs.stringify(data, {indices: false})
      }).then(res => {
        this.labelContact = res.data.list
        // 是否在部门组件
        if (this.isDepartLabel) {
          this.setLabelConcat()
        }
      })
    }
  }
}

export default label
